# -*- coding: utf-8 -*-
from __future__ import print_function


class ResourceInfo:
    def __init__(self, 
                 gpu_id, 
                 total_mem, # Bytes
                 node_id,
                 node_name):
        self.gpu_id = gpu_id
        self.node_id = node_id
        self.node_name = node_name
        self.total_mem = total_mem 
        self.available_mem = total_mem 
        self.idle = 1
        self.resource_id = self.node_name+'-'+str(self.node_id)+'-'+str(self.gpu_id)

    def update_available_mem(self, mem):
        self.available_mem = mem

    def set_busy(self):
        self.idle = 0

    def set_idel(self):
        self.idle = 1

    def is_idle(self):
        return self.idle

